#!/usr/bin/env python3
# - owner
# - repo
# - pr_num
# - comment
# gitee-comment

import os
import sys
sys.path.append(
    os.path.join(os.getenv("LKP_SRC"), "programs/gitee-comment-pr"))

from utils.gitee_proxy import GiteeProxy


lkp_src = os.getenv('LKP_SRC')
owner = os.getenv('owner')
repo = os.getenv('repo')
pr_num = os.getenv('pr_num')
comment = os.getenv('comment')
token = os.getenv('secrets_token')

gp = GiteeProxy(owner, repo, token)
commented = gp.comment_pr(pr_num, comment)

if not commented:
    raise RuntimeError(
        f"Comment to https://gitee.com/{owner}/{repo}/pulls/{pr_num} failed."
    )
